<template>
	<view class="integral">
		<van-cell-group class="integral-bg">
		  <van-field
			clearable
			:value="integral"
			type="number"
			input-class="integral-input"
			placeholder="请输入WNCT数量"
			@clear="onClear"
			@change="onChange"
		  />
		</van-cell-group>
		<view class="integral-info">
			<text class="integral-info-txt">实际转出：{{integral}}</text>
		</view>
		<view class="integral-info">
			<text class="integral-info-txt color-black">WNCT余额 {{balances}}</text>
			<text class="integral-info-btn" @click="onWNCTAllTransfer">全部转账</text>
		</view>
		<view class="integral-info">
			<text class="integral-info-txt">手续费</text>
			<text class="integral-info-txt">1%({{charge}}WNCT)</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				charge: 0,
				integral: '',
				balances: 50
			}
		},
		onLoad() {

		},
		methods: {
			onChange (e) {
				if (e.detail >= this.balances * 0.01) {
					this.onWNCTAllTransfer()
					return false
				}
				this.integral = e.detail
				this.charge = this.integral * 0.01
			},
			onClick () {
			},
			onClear () {
				this.charge = 0
			},
			onWNCTAllTransfer () {
				this.integral = this.balances * 0.99
				this.charge = this.balances * 0.01
			}
		}
	}
</script>

<style scoped lang="scss">
	.integral {
		padding: 40upx 30upx;
		background-color: #fff;
		&-ewm{
			display: flex;
			align-items: center;
			&-l {
				flex: 1;
			}
			&-r {
				width: 140upx;
			}
		}
		&-info {
			display: flex;
			justify-content: space-between;
			padding: 20upx 10upx;
			text {
				display: block;
			}
			&-txt {
				color: #9b9b9b;
				&.color-black {
					font-size: 28upx;
					color: #000;
				}
			}
			&-btn {
				font-size: 28upx;
				color: #0079f3;
			}
		}
	}
</style>
